#### Table 3: Group Threat on Gender Norms (Study 1) ####
## Author: Jeong Hyun Kim
## Last updated: 12/28/2021
rm(list=ls())
setwd("~/Dropbox/Gender Quota in Korea/Data")
library(foreign)
library(tidyverse)
library(broom)
library(stargazer)

#### Study 1: Loading Data and Coding variables ####
csid <- read.csv("survey_combined.csv", stringsAsFactors = FALSE)
csid$gov_support <- ifelse(csid$BQ14=="1", 1, 0)
# Coding young1: those in 20s and 30s
csid$young1 <- ifelse(csid$BQ3 < 40, 1, 0)
# Alternative operationalization of young variable
csid$young2 <- ifelse(csid$BQ3 < 40 & csid$BQ3 > 25, 1, 0)
# Alternative operationalization of young variable
csid$young3 <- ifelse(csid$BQ3 < 39 & csid$BQ3 > 22, 1, 0)  
names(csid)[3] <- "region"
csid$region <- as.factor(csid$region)
names(csid)[4] <- "age"
names(csid)[5] <- "education"
names(csid)[6] <- "occupation"
csid$occupation <- as.factor(csid$occupation)
names(csid)[7] <- "job_status"
csid[which(is.na(csid$job_status)), "job_status"] <- "other"
csid[which(csid$job_status=="#NULL!"),"job_status"] <- "other" # unemployed; retired; student
csid[which(csid$job_status=="1"),"job_status"] <- "regular"
csid[which(csid$job_status=="2"),"job_status"] <- "temp"
csid$temp_worker <- ifelse(csid$job_status=="temp", 1, 0)


names(csid)[8] <- "marital_status"
names(csid)[9] <- "children"
names(csid)[10] <- "religion"
names(csid)[11] <- "income"
names(csid)[12] <- "ideology"
names(csid)[13] <- "partyID"

# For BQ13, 99 is coded as don't know.
csid[which(csid$ideology=="99"),"ideology"] <- NA


#### Table 3 ####
mod3.1  <- lm(gender_role ~ treated +  as.factor(wave), csid)

mod3.2  <- lm(gender_role ~ treated+ as.factor(wave)+ age +  region + young1
              + education + income + as.factor(occupation) + ideology + as.factor(partyID)
              + econ_bad + as.factor(religion) + as.factor(marital_status) 
              + as.factor(children), csid)
mod3.3  <- lm(gender_role ~ treated*young1 +  as.factor(wave), csid)
mod3.4 <- lm(gender_role ~ treated*young1 +  as.factor(wave) + age +  region
             + education + income + as.factor(occupation) + ideology + as.factor(partyID)
             + econ_bad + as.factor(religion) + as.factor(marital_status) 
             + as.factor(children), csid)
